Skip to content

AbstractSliderMixin

Sub classes

Name Children Inherits
AbstractSlider
prettyqt.widgets.abstractslider
Integer value within a range.
    ScrollBarMixin
    prettyqt.widgets.scrollbar
    Slider
    prettyqt.widgets.slider
    Vertical or horizontal slider.
    Dial
    prettyqt.widgets.dial
    Rounded range control (like a speedometer or potentiometer).

      Base classes

      Name Children Inherits
      WidgetMixin
      prettyqt.widgets.widget
      object
      builtins
      The base class of the class hierarchy.
      • type
      • async_generator
      • bytearray_iterator
      • bytearray
      • bytes_iterator
      • bytes
      • builtin_function_or_method
      • callable_iterator
      • PyCapsule
      • cell
      • classmethod_descriptor
      • ...

        â‹” Inheritance diagram

        graph TD
          3920585708["widgets.AbstractSliderMixin"]
          829357528["widgets.WidgetMixin"]
          3227531497["core.ObjectMixin"]
          2751680898["builtins.object"]
          625385617["gui.PaintDeviceMixin"]
          829357528 --> 3920585708
          3227531497 --> 829357528
          2751680898 --> 3227531497
          625385617 --> 829357528
          2751680898 --> 625385617
          2751680898 --> 829357528
          2751680898 --> 3920585708

        🛈 DocStrings

        Bases: WidgetMixin, _AbstractSliderBase

        Source code in prettyqt/widgets/abstractslider.py
        class AbstractSliderMixin(widgets.WidgetMixin, _AbstractSliderBase):
            value_changed = core.Signal(int)
        
            def _get_map(self):
                maps = super()._get_map()
                maps |= {
                    "orientation": constants.ORIENTATION,
                }
                return maps
        
            def on_value_change(self):
                self.value_changed.emit(self.value())
        
            def is_horizontal(self) -> bool:
                """Check if silder is horizontal.
        
                Returns:
                    True if horizontal, else False
                """
                return self.orientation() == constants.HORIZONTAL
        
            def is_vertical(self) -> bool:
                """Check if silder is vertical.
        
                Returns:
                    True if vertical, else False
                """
                return self.orientation() == constants.VERTICAL
        
            def set_horizontal(self):
                """Set slider orientation to horizontal."""
                self.setOrientation(constants.HORIZONTAL)
        
            def set_vertical(self):
                """Set slider orientation to vertical."""
                self.setOrientation(constants.VERTICAL)
        
            def set_orientation(
                self, orientation: constants.OrientationStr | constants.Orientation
            ):
                """Set the orientation of the slider.
        
                Args:
                    orientation: orientation for the slider
                """
                self.setOrientation(constants.ORIENTATION.get_enum_value(orientation))
        
            def get_orientation(self) -> constants.OrientationStr:
                """Return current orientation.
        
                Returns:
                    orientation
                """
                return constants.ORIENTATION.inverse[self.orientation()]
        
            def scroll_to_min(self):
                """Scroll to the minimum value of the slider."""
                self.setValue(self.minimum())
        
            def scroll_to_max(self):
                """Scroll to the maximum value of the slider."""
                self.setValue(self.maximum())
        
            def set_range(self, min_val: int, max_val: int):
                self.setRange(min_val, max_val)
        
            def set_step_size(self, step_size: int):
                self.setSingleStep(step_size)
        
            def set_repeat_action(
                self,
                action: SliderActionStr | widgets.QAbstractSlider.SliderAction,
                threshold: int = 500,
                repeat_time: int = 50,
            ):
                """Set the repeat action.
        
                Args:
                    action: repeat action
                    threshold: initial delay in ms
                    repeat_time: repeat time in ms
                """
                self.setRepeatAction(SLIDER_ACTION.get_enum_value(action), threshold, repeat_time)
        
            def get_repeat_action(self) -> SliderActionStr:
                """Get current repeat action.
        
                Returns:
                    current repeat action
                """
                return SLIDER_ACTION.inverse[self.repeatAction()]
        
            def trigger_action(
                self, action: SliderActionStr | widgets.QAbstractSlider.SliderAction
            ):
                """Trigger slider action."""
                self.triggerAction(SLIDER_ACTION.get_enum_value(action))
        
            def get_value(self) -> int:
                return self.value()
        
            def set_value(self, value: int):
                self.setValue(value)
        
            def on_scrollbar_range_changed(self, minval: int, maxval: int):
                if self.value() >= self.maximum() - 1:
                    self.setValue(maxval)
        
            def set_auto_scroll_to_end(self, scroll: bool = True):
                """Set to always scroll to the end when range changes."""
                if scroll:
                    self.rangeChanged.connect(self.on_scrollbar_range_changed)
                else:
                    self.rangeChanged.disconnect(self.on_scrollbar_range_changed)
        

        get_orientation() -> constants.OrientationStr

        Return current orientation.

        Source code in prettyqt/widgets/abstractslider.py
        def get_orientation(self) -> constants.OrientationStr:
            """Return current orientation.
        
            Returns:
                orientation
            """
            return constants.ORIENTATION.inverse[self.orientation()]
        

        get_repeat_action() -> SliderActionStr

        Get current repeat action.

        Source code in prettyqt/widgets/abstractslider.py
        def get_repeat_action(self) -> SliderActionStr:
            """Get current repeat action.
        
            Returns:
                current repeat action
            """
            return SLIDER_ACTION.inverse[self.repeatAction()]
        

        is_horizontal() -> bool

        Check if silder is horizontal.

        Source code in prettyqt/widgets/abstractslider.py
        def is_horizontal(self) -> bool:
            """Check if silder is horizontal.
        
            Returns:
                True if horizontal, else False
            """
            return self.orientation() == constants.HORIZONTAL
        

        is_vertical() -> bool

        Check if silder is vertical.

        Source code in prettyqt/widgets/abstractslider.py
        def is_vertical(self) -> bool:
            """Check if silder is vertical.
        
            Returns:
                True if vertical, else False
            """
            return self.orientation() == constants.VERTICAL
        

        scroll_to_max()

        Scroll to the maximum value of the slider.

        Source code in prettyqt/widgets/abstractslider.py
        def scroll_to_max(self):
            """Scroll to the maximum value of the slider."""
            self.setValue(self.maximum())
        

        scroll_to_min()

        Scroll to the minimum value of the slider.

        Source code in prettyqt/widgets/abstractslider.py
        def scroll_to_min(self):
            """Scroll to the minimum value of the slider."""
            self.setValue(self.minimum())
        

        set_auto_scroll_to_end(scroll: bool = True)

        Set to always scroll to the end when range changes.

        Source code in prettyqt/widgets/abstractslider.py
        def set_auto_scroll_to_end(self, scroll: bool = True):
            """Set to always scroll to the end when range changes."""
            if scroll:
                self.rangeChanged.connect(self.on_scrollbar_range_changed)
            else:
                self.rangeChanged.disconnect(self.on_scrollbar_range_changed)
        

        set_horizontal()

        Set slider orientation to horizontal.

        Source code in prettyqt/widgets/abstractslider.py
        def set_horizontal(self):
            """Set slider orientation to horizontal."""
            self.setOrientation(constants.HORIZONTAL)
        

        set_orientation(orientation: constants.OrientationStr | constants.Orientation)

        Set the orientation of the slider.

        Parameters:

        Name Type Description Default
        orientation OrientationStr | Orientation

        orientation for the slider

        required
        Source code in prettyqt/widgets/abstractslider.py
        def set_orientation(
            self, orientation: constants.OrientationStr | constants.Orientation
        ):
            """Set the orientation of the slider.
        
            Args:
                orientation: orientation for the slider
            """
            self.setOrientation(constants.ORIENTATION.get_enum_value(orientation))
        

        set_repeat_action(action: SliderActionStr | widgets.QAbstractSlider.SliderAction, threshold: int = 500, repeat_time: int = 50)

        Set the repeat action.

        Parameters:

        Name Type Description Default
        action SliderActionStr | SliderAction

        repeat action

        required
        threshold int

        initial delay in ms

        500
        repeat_time int

        repeat time in ms

        50
        Source code in prettyqt/widgets/abstractslider.py
        def set_repeat_action(
            self,
            action: SliderActionStr | widgets.QAbstractSlider.SliderAction,
            threshold: int = 500,
            repeat_time: int = 50,
        ):
            """Set the repeat action.
        
            Args:
                action: repeat action
                threshold: initial delay in ms
                repeat_time: repeat time in ms
            """
            self.setRepeatAction(SLIDER_ACTION.get_enum_value(action), threshold, repeat_time)
        

        set_vertical()

        Set slider orientation to vertical.

        Source code in prettyqt/widgets/abstractslider.py
        def set_vertical(self):
            """Set slider orientation to vertical."""
            self.setOrientation(constants.VERTICAL)
        

        trigger_action(action: SliderActionStr | widgets.QAbstractSlider.SliderAction)

        Trigger slider action.

        Source code in prettyqt/widgets/abstractslider.py
        def trigger_action(
            self, action: SliderActionStr | widgets.QAbstractSlider.SliderAction
        ):
            """Trigger slider action."""
            self.triggerAction(SLIDER_ACTION.get_enum_value(action))
        

        :fa-brands-github: Show source on GitHub